package com.zhuiyi.springzhuiyi.model;

import com.zhuiyi.springzhuiyi.model.Person;

import java.util.ArrayList;
import java.util.stream.Stream;

/**
 * Create By 刘珈玮 on 2020/3/12.
 */
public class Demo1 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();

        list.add("1,ljw,22");
        list.add("2,lzw,36");
        list.add("3,lq,46");
        list.add("4,lb,56");
        list.add("5,fsc,66");
        list.add("6,zwj,76");

        System.out.println(list);

        Stream<Person> personStream = list.stream().map(s -> {
            String[] split = s.split(",");
            Person person = new Person();

            person.setId(Integer.parseInt(split[0]));
            person.setName(split[1]);
            person.setAge(Integer.parseInt(split[2]));

            return person;
        });

        personStream.forEach(System.out::println);
    }
}
